/*
 * ConfirmPayWayActivity.java
 * business
 *
 * Created by chentao on 2017/5/3.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.main.shoppingcart.cashier;

import android.app.Activity;
import android.content.Intent;

import com.yidiandao.business.R;
import com.yidiandao.business.base.BaseActivity;
import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.utils.ActivityUtils;

/**
 * 收银台-Activity.
 */
public class CashierActivity extends BaseActivity {

    private CashierFragment mCashierFragment;

    public static void actionStart(Activity activity, String url, String orderPayId, String totalOnlinePay, boolean allOnlinePay) {
        Intent intent = new Intent(activity, CashierActivity.class);
        intent.putExtra(Intents.HTTP_URL, url);
        intent.putExtra(Intents.EXTRA_ORDER_PAY_ID, orderPayId);
        intent.putExtra(Intents.EXTRA_ORDER_ONLINE_PAY_MONEY, totalOnlinePay);
        intent.putExtra(Intents.EXTRA_ALL_ONLINE_PAY, allOnlinePay);
        activity.startActivity(intent);
    }

    @Override
    protected void initFragment() {
        mCashierFragment = (CashierFragment) getSupportFragmentManager().findFragmentById(R.id.container_cashier);

        if (mCashierFragment == null) {
            mCashierFragment = CashierFragment.getInstance();
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), mCashierFragment, R.id.container_cashier);
        }

    }

    @Override
    protected void initPresenter() {
        new CashierPresenter(mCashierFragment, getIntent().getExtras());
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_cashier;
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        mCashierFragment.onBackPress();
    }
}
